<div class="boxed clearfix">
  <div class="common-tit">
    <h2>市场专员详情</h2>
    <span>团队管理 > 月指标列表 > 专员详情</span>
  </div>
  <div class="market">
    <h3>意向学员列表</h3>
    <div class="mar-listbox clearfix">
      <div class="list-box">
        <div class="downbtn">
          <span data_id="all">请选择性别</span>
          <em></em>
        </div>
        <ul class="dropdown-menu">
          <li data_id="all">请选择性别</li>
          <li data_id="男">男</li>
          <li data_id="女">女</li>
        </ul>
      </div>
      <div class="list-box">
        <div class="downbtn">
          <span data_id="all">请选择年龄分组</span>
          <em></em>
        </div>
        <ul class="dropdown-menu">
          <li data_id="all">请选择年龄分组</li>
          <% Company::AGE_GROUP.each do |key, value| %>
            <li data_id="<%= key %>"><%= value %></li>
          <%end%>
        </ul>
      </div>
      <div class="list-box">
        <div class="downbtn">
          <span data_id="all">请选择学员分组</span>
          <em></em>
        </div>
        <ul class="dropdown-menu">
          <li data_id="all">请选择学员分组</li>
          <% @student_group.each do |sg| %>
            <li data_id="<%= sg.id %>"><%= sg.group_name %></li>
          <% end %>
        </ul>
      </div>
      <div class="list-box">
        <div class="downbtn">
          <span data_id="all">请选择意向分店</span>
          <em></em>
        </div>
        <ul class="dropdown-menu">
          <li data_id="all">请选择意向分店</li>
          <% @studios.each do |studio| %>
            <li data_id="<%= studio.id %>"><%= studio.name %></li>
          <% end %>
        </ul>
      </div>
      <div class="list-box">
        <div class="downbtn">
          <span data_id="all">请选择转化状态</span>
          <em></em>
        </div>
        <ul class="dropdown-menu">
          <li data_id="all">请选择转化状态</li>
          <li data_id="已转化">已转化</li>
          <li data_id="未转化">未转化</li>
        </ul>
      </div>
    </div>
  </div>
  <div class="indi-con">
    <div class="scrollbox">
      <table>
        <thead>
          <tr>
            <th class="indi-name">姓名</th>
            <th class="indi-sex">性别</th>
            <th class="indi-age">年龄阶段</th>
            <th class="indi-group">分组</th>
            <th class="indi-int">意向分店</th>
            <th class="indi-state">状态</th>
          </tr>
        </thead>
        <tbody>
          <% @potential_students.each do |ps| %>
          <tr>
            <td><%= ps.name %></td>
            <td><%= ps.sex %></td>
            <td><%= ps.student_age_group %></td>
            <td><%= ps.student_group_configuration.group_name if ps.student_group%></td>
            <td><%= ps.intention_studio.name if ps.willing_studio %></td>
            <td><%= ps.status %></td>
          </tr>
          <% end %>
        </tbody>
      </table>
    </div>
  </div>
</div>
<script src="/assets/js/jquery-1.12.3.js"></script>
<script src="/assets/js/common-list.js"></script>
<script type="text/javascript">
  $(".mar-listbox .list-box li").on("click", function() {
    $(this).parent().parent().find("span").attr("data_id", $(this).attr("data_id"));
    transData();
  });
  function transData() {
    var transD = "month=" + "<%= @month %>" + "&target_id=<%= @target.id %>&" ;
    for (var i = 0; i < $(".mar-listbox .list-box").length; i++) {
      switch(true) {
        case i == 0: transD += "sex" + "=" + $($(".mar-listbox .list-box")[i]).find("span").attr("data_id") + "&";break;
        case i == 1: transD += "age_group" + "=" + $($(".mar-listbox .list-box")[i]).find("span").attr("data_id") + "&";break;
        case i == 2: transD += "student_group" + "=" + $($(".mar-listbox .list-box")[i]).find("span").attr("data_id") + "&";break;
        case i == 3: transD += "willing_studio" + "=" + $($(".mar-listbox .list-box")[i]).find("span").attr("data_id") + "&";break;
        case i == 4: transD += "status" + "=" + $($(".mar-listbox .list-box")[i]).find("span").attr("data_id");break;

      };
    };
    console.log(transD);
    $.ajax({
      type:'get', url:"/admin/targets/get_market_detail_list?"+ transD,
      success: function(data) {
        if (data.error) {
          // console.log("wrong");
        } 
      }
    });
  };
</script>
